﻿using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for TmdbTrailerTest and is intended
    ///     to contain all TmdbTrailerTest Unit Tests
    /// </summary>
    [TestClass]
    public class TmdbTrailerTest
    {
        /// <summary>
        ///     A test for TmdbTrailer Constructor
        /// </summary>
        [TestMethod]
        public void TmdbTrailerConstructorTest()
        {
            var target = new TmdbTrailer();
            Assert.IsNotNull( target );
        }

        /// <summary>
        ///     A test for Name
        /// </summary>
        [TestMethod]
        public void NameTest()
        {
            var target = new TmdbTrailer();
            string expected = Guid.NewGuid().ToString();
            string actual;
            target.Name = expected;
            actual = target.Name;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Size
        /// </summary>
        [TestMethod]
        public void SizeTest()
        {
            var target = new TmdbTrailer();
            string expected = Guid.NewGuid().ToString();
            string actual;
            target.Size = expected;
            actual = target.Size;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Source
        /// </summary>
        [TestMethod]
        public void SourceTest()
        {
            var target = new TmdbTrailer();
            string expected = Guid.NewGuid().ToString();
            string actual;
            target.Source = expected;
            actual = target.Source;
            Assert.AreEqual( expected, actual );
        }

        [TestMethod]
        [DeploymentItem(@"..\..\TestData\trailer.json.txt")]
        public async Task SerializeDeserializeTest()
        {
            var target = new TmdbTrailer();
            var jsonContent = File.ReadAllText("trailer.json.txt");
            var actual = await target.DeserializeJson<TmdbTrailer>(jsonContent);

            Assert.AreEqual("Trailer", actual.Name);
            Assert.AreEqual("HD", actual.Size);
            Assert.AreEqual("zA92Rw6kNWw", actual.Source);
        }
    }
}